/**
 * 
 */
package com.feonix.designPattern.Iterator.sample;

/**
 * @CopyRight (c)1993-2017
 * @Project common_practice
 * @Comments 请输入该类的描述
 * @NameSpace com.feonix.designPattern.Iterator.sample
 * @Author Feonixzw
 * @CreateDate 2018年1月24日
 */
public class BookShelfIterator implements Iterator {

	private BookShelf bookShelf;

	private int index;

	public BookShelfIterator(BookShelf bookShelf) {
		this.bookShelf = bookShelf;
		this.index = 0;
	}

	@Override
	public boolean hasNext() {
		if (index < bookShelf.getLength()) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public Object next() {
		Book book = bookShelf.getBookAt(this.index);
		index++;
		return book;
	}
}
